#include "BindGraphics.hpp"

using namespace luabind;
namespace bind
{
	namespace SFML
	{
		namespace graphics
		{				
			void BDrawable(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Drawable_wrapper>("Drawable_wrapper"),
						class_<sf::Drawable, bases<sf::Drawable_wrapper> >("Drawable")

							/*.def(constructor<const sf::Vector2f&, const sf::Vector2f&, float, const sf::Color&>())
							.property("myPosition", &sf::Drawable::GetPosition, (void(sf::Drawable::*)(const sf::Vector2f&))&sf::Drawable::SetPosition)
							.def("myPosition", (void(sf::Drawable::*)(float, float))&sf::Drawable::SetPosition)
							.def("SetX", &sf::Drawable::SetX)
							.def("SetY", &sf::Drawable::SetY)
							.def("myScale", &sf::Drawable::GetScale, (void(sf::Drawable::*)(const sf::Vector2f&))&sf::Drawable::SetScale)
							.def("SetScale", (void(sf::Drawable::*)(float, float))&sf::Drawable::SetScale)
							.def("SetScaleX", &sf::Drawable::SetScaleX)
							.def("SetScaleY", &sf::Drawable::SetScaleY)
							.def("myOrigin", &sf::Drawable::GetOrigin, (void(sf::Drawable::*)(const sf::Vector2f&))&sf::Drawable::SetOrigin)
							.def("SetOrigin", (void(sf::Drawable::*)(float, float))&sf::Drawable::SetOrigin)
							.def("myRotation", &sf::Drawable::GetRotation, &sf::Drawable::SetRotation)
							.def("myColor", &sf::Drawable::GetColor, &sf::Drawable::SetColor)
							.def("myBlendMode", &sf::Drawable::GetBlendMode, &sf::Drawable::SetBlendMode)
							.def("Move", (void(sf::Drawable::*)(float, float))&sf::Drawable::Move)
							.def("Move", (void(sf::Drawable::*)(const sf::Vector2f&))&sf::Drawable::Move)
							.def("Scale", (void(sf::Drawable::*)(float, float))&sf::Drawable::Scale)
							.def("Scale", (void(sf::Drawable::*)(const sf::Vector2f&))&sf::Drawable::Scale)
							.def("Rotate", &sf::Drawable::Rotate)
							.def("TransformToLocal", &sf::Drawable::TransformToLocal)
							.def("TransformToGlobal", &sf::Drawable::TransformToGlobal)*/
					];

				object mode = newtable(lua);
				mode["Alpha"] = sf::Blend::Mode::Alpha;
				mode["Add"] = sf::Blend::Mode::Add;
				mode["Multiply"] = sf::Blend::Mode::Multiply;
				mode["None"] = sf::Blend::Mode::None;
				globals(lua)[ns.c_str()]["Blend"] = newtable(lua);
				globals(lua)[ns.c_str()]["Blend"]["Mode"] = mode;
			}

			void BColor(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Color>("Color")
							.def(constructor<>())
							.def(constructor<sf::Uint8, sf::Uint8, sf::Uint8, sf::Uint8>())
							.def(const_self == sf::Color())
							.def(const_self + sf::Color())
							.def(const_self * sf::Color())

							.def_readwrite("r", &sf::Color::r)
							.def_readwrite("g", &sf::Color::g)
							.def_readwrite("b", &sf::Color::b)
							.def_readwrite("a", &sf::Color::a)
					];

					LUA_CONST_START(lua, sf::Color)
					LUA_CONST(sf::Color, Black)
					LUA_CONST(sf::Color, White)
					LUA_CONST(sf::Color, Red)
					LUA_CONST(sf::Color, Green)
					LUA_CONST(sf::Color, Yellow)
					LUA_CONST(sf::Color, Magenta)
					LUA_CONST(sf::Color, Cyan)
					LUA_CONST_END
					
			}
				
			void BFont(lua_State* lua, const std::string& ns)
			{
			//Arial.hpp
			//FonLoader
				module(lua, ns.c_str())
					[
						class_<sf::Resource<sf::Font> >("FontResource"),
						class_<sf::Font, bases<sf::Resource<sf::Font> > >("Font")
							.def(constructor<>())
							.def(constructor<const sf::Font&>())
							.def("LoadFromFile", &sf::Font::LoadFromFile)
							.def("LoadFromMemory", &sf::Font::LoadFromMemory)
							.def("GetGlyph", &sf::Font::GetGlyph)
							.def("GetKerning", &sf::Font::GetKerning)
							.def("GetLineSpacing", &sf::Font::GetLineSpacing)
							.def("GetImage", &sf::Font::GetImage)
							.def("GetDefaultFont", &sf::Font::GetDefaultFont)
					];

			}
				
			void BGlyph(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Glyph>("Glyph")
							.def(constructor<>())
							.def_readwrite("Advance", &sf::Glyph::Advance)
							.def_readwrite("Bounds", &sf::Glyph::Bounds)
							.def_readwrite("SubRect", &sf::Glyph::SubRect)
					];
			}
				
			void BImage(lua_State* lua, const std::string& ns)
			{
			//ImageLoader
				module(lua, ns.c_str())
					[
						class_<sf::Image>("Image")
							.def(constructor<>())
							.def(constructor<const sf::Image&>())
							.def("LoadFromFile", &sf::Image::LoadFromFile)
							.def("LoadFromMemory", &sf::Image::LoadFromMemory)
							.def("LoadFromPixels", &sf::Image::LoadFromPixels)
							.def("SaveToFile", &sf::Image::SaveToFile)
							.def("Create", &sf::Image::Create)
							.def("CreateMaskFromColor", &sf::Image::CreateMaskFromColor)
							.def("Copy", &sf::Image::Copy)
							.def("CopyScreen", &sf::Image::CopyScreen)
							.def("SetPixel", &sf::Image::SetPixel)
							.def("GetPixel", &sf::Image::GetPixel)
							.def("GetPixelsPtr", &sf::Image::GetPixelsPtr)
							.def("UpdatePixels", (void(sf::Image::*)(const sf::Uint8*))&sf::Image::UpdatePixels)
							.def("UpdatePixels", (void(sf::Image::*)(const sf::Uint8*, const sf::IntRect&))&sf::Image::UpdatePixels)
							.def("Bind", &sf::Image::Bind)
							.def("SetSmooth", &sf::Image::SetSmooth)
							.def("IsSmooth", &sf::Image::IsSmooth)
							.def("GetWidth", &sf::Image::GetWidth)
							.def("GetHeight", &sf::Image::GetHeight)
							.def("GetTexCoords", &sf::Image::GetTexCoords)
							.def("GetMaximumSize", &sf::Image::GetMaximumSize)
					];
			}

			void BRenderer(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Renderer>("Renderer")
							.def(constructor<sf::RenderTarget&>())
							.def("Initialize", &sf::Renderer::Initialize)
							.def("SaveGLStates", &sf::Renderer::SaveGLStates)
							.def("RestoreGLStates", &sf::Renderer::RestoreGLStates)
							.def("Clear", &sf::Renderer::Clear)
							.def("PushStates", &sf::Renderer::PushStates)
							.def("PopStates", &sf::Renderer::PopStates)
							.def("SetModelView", &sf::Renderer::SetModelView)
							.def("ApplyModelView", &sf::Renderer::ApplyModelView)
							.def("SetProjection", &sf::Renderer::SetProjection)
							.def("SetColor", &sf::Renderer::SetColor)
							.def("ApplyColor", &sf::Renderer::ApplyColor)
							.def("SetViewport", &sf::Renderer::SetViewport)
							.def("SetBlendMode", &sf::Renderer::SetBlendMode)
							.def("SetTexture", &sf::Renderer::SetTexture)
							.def("SetShader", &sf::Renderer::SetShader)
							.def("Begin", &sf::Renderer::Begin)
							.def("End", &sf::Renderer::End)
							.def("AddVertex", (void(sf::Renderer::*)(float, float))&sf::Renderer::AddVertex)
							.def("AddVertex", (void(sf::Renderer::*)(float, float, float, float))&sf::Renderer::AddVertex)
							.def("AddVertex", (void(sf::Renderer::*)(float, float, const sf::Color&))&sf::Renderer::AddVertex)
							.def("AddVertex", (void(sf::Renderer::*)(float, float, float, float, const sf::Color&))&sf::Renderer::AddVertex)
					];

				object type = newtable(lua);
				type["TriangleList"] = sf::Renderer::PrimitiveType::TriangleList;
				type["TriangleStrip"] = sf::Renderer::PrimitiveType::TriangleStrip;
				type["TriangleFan"] = sf::Renderer::PrimitiveType::TriangleFan;
				type["QuadList"] = sf::Renderer::PrimitiveType::QuadList;
				globals(lua)[ns.c_str()]["Renderer"]["PrimitiveType"] = type;
			}

			void BRenderImage(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::RenderImage, bases<sf::RenderTarget> >("RenderImage")
							.def(constructor<>())
							.def("Create", &sf::RenderImage::Create)
							.def("SetSmooth", &sf::RenderImage::SetSmooth)
							.def("IsSmooth", &sf::RenderImage::IsSmooth)
							.def("SetActive", &sf::RenderImage::SetActive)
							.def("Display", &sf::RenderImage::Display)
							.def("GetWidth", &sf::RenderImage::GetWidth)
							.def("GetHeight", &sf::RenderImage::GetHeight)
							.def("GetImage", &sf::RenderImage::GetImage)
							.def("Clear", &sf::RenderImage::Clear)
							.def("Draw", (void(sf::RenderImage::*)(const sf::Drawable&))&sf::RenderImage::Draw)
							.def("Draw", (void(sf::RenderImage::*)(const sf::Drawable&, const sf::Shader&))&sf::RenderImage::Draw)
							.def("SetView", &sf::RenderImage::SetView)
							.def("GetView", &sf::RenderImage::GetView)
							.def("GetDefaultView", &sf::RenderImage::GetDefaultView)
							.def("GetViewport", &sf::RenderImage::GetViewport)							
							.def("SaveGLStates", &sf::RenderImage::SaveGLStates)
							.def("RestoreGLStates", &sf::RenderImage::RestoreGLStates)
							.def("IsAvailable", &sf::RenderImage::IsAvailable)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderImage::*)(unsigned int, unsigned int) const)&sf::RenderImage::ConvertCoords)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderImage::*)(unsigned int, unsigned int, const sf::View&) const)&sf::RenderImage::ConvertCoords)
					];
			}
				
			void BRenderTarget(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::RenderTarget>("RenderTarget")
							.def("Clear", &sf::RenderTarget::Clear)
							.def("Draw", (void(sf::RenderTarget::*)(const sf::Drawable&))&sf::RenderTarget::Draw)
							.def("Draw", (void(sf::RenderTarget::*)(const sf::Drawable&, const sf::Shader&))&sf::RenderTarget::Draw)
							.def("GetWidth", &sf::RenderTarget::GetWidth)
							.def("GetHeight", &sf::RenderTarget::GetHeight)
							.def("SetView", &sf::RenderTarget::SetView)
							.def("GetView", &sf::RenderTarget::GetView)
							.def("GetDefaultView", &sf::RenderTarget::GetDefaultView)
							.def("GetViewport", &sf::RenderTarget::GetViewport)
							.def("SaveGLStates", &sf::RenderTarget::SaveGLStates)
							.def("RestoreGLStates", &sf::RenderTarget::RestoreGLStates)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderTarget::*)(unsigned int, unsigned int) const)&sf::RenderTarget::ConvertCoords)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderTarget::*)(unsigned int, unsigned int, const sf::View&) const)&sf::RenderTarget::ConvertCoords)
					];
			}
				
			void BRenderWindow(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::RenderWindow, bases<sf::Window, sf::RenderTarget> >("RenderWindow")
							.def(constructor<>())
							.def(constructor<sf::VideoMode, const std::string&, unsigned long, const sf::ContextSettings&>())
							.def(constructor<sf::WindowHandle, const sf::ContextSettings&>())
							.def("GetWidth", &sf::RenderWindow::GetWidth)
							.def("GetHeight", &sf::RenderWindow::GetHeight)
							.def("Create", (void(sf::RenderWindow::*)(sf::VideoMode, const std::string&, unsigned long, const sf::ContextSettings&))&sf::RenderWindow::Create)
							.def("Create", (void(sf::RenderWindow::*)(sf::WindowHandle, const sf::ContextSettings&))&sf::RenderWindow::Create)
							.def("Close", &sf::RenderWindow::Close)
							.def("IsOpened", &sf::RenderWindow::IsOpened)
							.def("GetSettings", &sf::RenderWindow::GetSettings)
							.def("GetEvent", &sf::RenderWindow::GetEvent)
							.def("WaitEvent", &sf::RenderWindow::WaitEvent)
							.def("UseVerticalSync", &sf::RenderWindow::UseVerticalSync)
							.def("ShowMouseCursor", &sf::RenderWindow::ShowMouseCursor)
							.def("SetCursorPosition", &sf::RenderWindow::SetCursorPosition)
							.def("SetPosition", &sf::RenderWindow::SetPosition)
							.def("SetSize", &sf::RenderWindow::SetSize)
							.def("SetTitle", &sf::RenderWindow::SetTitle)
							.def("Show", &sf::RenderWindow::Show)
							.def("EnableKeyRepeat", &sf::RenderWindow::EnableKeyRepeat)
							.def("SetIcon", &sf::RenderWindow::SetIcon)
							.def("SetActive", &sf::RenderWindow::SetActive)
							.def("Display", &sf::RenderWindow::Display)
							.def("GetInput", &sf::RenderWindow::GetInput)
							.def("SetFramerateLimit", &sf::RenderWindow::SetFramerateLimit)
							.def("GetFrameTime", &sf::RenderWindow::GetFrameTime)
							.def("SetJoystickThreshold", &sf::RenderWindow::SetJoystickThreshold)
							.def("GetSystemHandle", &sf::RenderWindow::GetSystemHandle)
							.def("Clear", &sf::RenderWindow::Clear)
							.def("Draw", (void(sf::RenderWindow::*)(const sf::Drawable&))&sf::RenderWindow::Draw)
							.def("Draw", (void(sf::RenderWindow::*)(const sf::Drawable&, const sf::Shader&))&sf::RenderWindow::Draw)
							.def("SetView", &sf::RenderWindow::SetView)
							.def("GetView", &sf::RenderWindow::GetView)
							.def("GetDefaultView", &sf::RenderWindow::GetDefaultView)
							.def("GetViewport", &sf::RenderWindow::GetViewport)							
							.def("SaveGLStates", &sf::RenderWindow::SaveGLStates)
							.def("RestoreGLStates", &sf::RenderWindow::RestoreGLStates)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderWindow::*)(unsigned int, unsigned int) const)&sf::RenderWindow::ConvertCoords)
							.def("ConvertCoords", (sf::Vector2f(sf::RenderWindow::*)(unsigned int, unsigned int, const sf::View&) const)&sf::RenderWindow::ConvertCoords)
					];
			}
			
			void BShader(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Shader>("Shader")
							.def(constructor<>())
							.def(constructor<const sf::Shader&>())
							.def("LoadFromFile", &sf::Shader::LoadFromFile)
							.def("LoadFromMemory", &sf::Shader::LoadFromMemory)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, float))&sf::Shader::SetParameter)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, float, float))&sf::Shader::SetParameter)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, float, float, float))&sf::Shader::SetParameter)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, float, float, float, float))&sf::Shader::SetParameter)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, const sf::Vector2f&))&sf::Shader::SetParameter)
							.def("SetParameter", (void(sf::Shader::*)(const std::string&, const sf::Vector3f&))&sf::Shader::SetParameter)
							.def("SetTexture", &sf::Shader::SetTexture)
							.def("Bind", &sf::Shader::Bind)
							.def("Unbind", &sf::Shader::Unbind)
							.def("IsAvailable", &sf::Shader::IsAvailable)
					];

					LUA_CONST_START(lua, sf::Shader)
					LUA_CONST(sf::Shader, CurrentTexture)
					LUA_CONST_END
			}
				
			void BShape(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Shape, bases<sf::Drawable> >("Shape")
							.def(constructor<>())
							.def("AddPoint", (void(sf::Shape::*)(float, float, const sf::Color&, const sf::Color&))&sf::Shape::AddPoint)
							.def("AddPoint", (void(sf::Shape::*)(const sf::Vector2f&, const sf::Color&, const sf::Color&))&sf::Shape::AddPoint)
							.def("GetPointsCount", &sf::Shape::GetPointsCount)
							.def("EnableFill", &sf::Shape::EnableFill)
							.def("EnableOutline", &sf::Shape::EnableOutline)
							.def("SetPointPosition", (void(sf::Shape::*)(unsigned int, const sf::Vector2f&))&sf::Shape::SetPointPosition)
							.def("SetPointPosition", (void(sf::Shape::*)(unsigned int, float, float))&sf::Shape::SetPointPosition)
							.def("SetPointColor", &sf::Shape::SetPointColor)
							.def("SetPointOutlineColor", &sf::Shape::SetPointOutlineColor)
							.def("SetOutlineWidth", &sf::Shape::SetOutlineWidth)
							.def("GetPointPosition", &sf::Shape::GetPointPosition)
							.def("GetPointColor", &sf::Shape::GetPointColor)
							.def("GetPointOutlineColor", &sf::Shape::GetPointOutlineColor)
							.def("GetOutlineWidth", &sf::Shape::GetOutlineWidth)
							.def("SetPosition", (void(sf::Shape::*)(float, float))&sf::Shape::SetPosition)
							.def("SetPosition", (void(sf::Shape::*)(const sf::Vector2f&))&sf::Shape::SetPosition)
							.def("SetX", &sf::Shape::SetX)
							.def("SetY", &sf::Shape::SetY)
							.def("SetScale", (void(sf::Shape::*)(float, float))&sf::Shape::SetScale)
							.def("SetScale", (void(sf::Shape::*)(const sf::Vector2f&))&sf::Shape::SetScale)
							.def("SetScaleX", &sf::Shape::SetScaleX)
							.def("SetScaleY", &sf::Shape::SetScaleY)
							.def("SetOrigin", (void(sf::Shape::*)(float, float))&sf::Shape::SetOrigin)
							.def("SetOrigin", (void(sf::Shape::*)(const sf::Vector2f&))&sf::Shape::SetOrigin)
							.def("SetRotation", &sf::Shape::SetRotation)
							.def("SetColor", &sf::Shape::SetColor)
							.def("SetBlendMode", &sf::Shape::SetBlendMode)
							.def("GetPosition", &sf::Shape::GetPosition)
							.def("GetScale", &sf::Shape::GetScale)
							.def("GetOrigin", &sf::Shape::GetOrigin)
							.def("GetRotation", &sf::Shape::GetRotation)
							.def("GetColor", &sf::Shape::GetColor)
							.def("GetBlendMode", &sf::Shape::GetBlendMode)
							.def("Move", (void(sf::Shape::*)(float, float))&sf::Shape::Move)
							.def("Move", (void(sf::Shape::*)(const sf::Vector2f&))&sf::Shape::Move)
							.def("Scale", (void(sf::Shape::*)(float, float))&sf::Shape::Scale)
							.def("Scale", (void(sf::Shape::*)(const sf::Vector2f&))&sf::Shape::Scale)
							.def("Rotate", &sf::Shape::Rotate)
							.def("TransformToLocal", &sf::Shape::TransformToLocal)
							.def("TransformToGlobal", &sf::Shape::TransformToGlobal)
							.def("Line", (sf::Shape(*)(sf::Shape&, float, float, float, float, float, const sf::Color&, float, const sf::Color&))&sf::LineShape)
							.def("Line", (sf::Shape(*)(sf::Shape&, const sf::Vector2f&, const sf::Vector2f&, float, const sf::Color&, float, const sf::Color&))&sf::LineShape)
							.def("Rectangle", (sf::Shape(*)(sf::Shape&, float, float, float, float, const sf::Color&, float, const sf::Color&))&sf::RectangleShape)
							.def("Rectangle", (sf::Shape(*)(sf::Shape&, const sf::FloatRect&, const sf::Color&, float, const sf::Color&))&sf::RectangleShape)
							.def("Circle", (sf::Shape(*)(sf::Shape&, float, float, float, const sf::Color&, float, const sf::Color&))&sf::CircleShape)
							.def("Circle", (sf::Shape(*)(sf::Shape&, const sf::Vector2f&, float, const sf::Color&, float, const sf::Color&))&sf::CircleShape)
					];
			}
				
			void BSprite(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Sprite, bases<sf::Drawable> >("Sprite")
							.def(constructor<>())
							.def(constructor<const sf::Image&, const sf::Vector2f&, const sf::Vector2f&, float, const sf::Color&>())
							.def("SetImage", &sf::Sprite::SetImage)
							.def("SetSubRect", &sf::Sprite::SetSubRect)
							.def("Resize", (void(sf::Sprite::*)(float, float))&sf::Sprite::Resize)
							.def("Resize", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::Resize)
							.def("FlipX", &sf::Sprite::FlipX)
							.def("FlipY", &sf::Sprite::FlipY)
							.def("GetImage", &sf::Sprite::GetImage)
							.def("GetSubRect", &sf::Sprite::GetSubRect)
							.def("GetSize", &sf::Sprite::GetSize)
							.def("GetPixel", &sf::Sprite::GetPixel)
							.def("SetPosition", (void(sf::Sprite::*)(float, float))&sf::Sprite::SetPosition)
							.def("SetPosition", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::SetPosition)
							.def("SetX", &sf::Sprite::SetX)
							.def("SetY", &sf::Sprite::SetY)
							.def("SetScale", (void(sf::Sprite::*)(float, float))&sf::Sprite::SetScale)
							.def("SetScale", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::SetScale)
							.def("SetScaleX", &sf::Sprite::SetScaleX)
							.def("SetScaleY", &sf::Sprite::SetScaleY)
							.def("SetOrigin", (void(sf::Sprite::*)(float, float))&sf::Sprite::SetOrigin)
							.def("SetOrigin", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::SetOrigin)
							.def("SetRotation", &sf::Sprite::SetRotation)
							.def("SetColor", &sf::Sprite::SetColor)
							.def("SetBlendMode", &sf::Sprite::SetBlendMode)
							.def("GetPosition", &sf::Sprite::GetPosition)
							.def("GetScale", &sf::Sprite::GetScale)
							.def("GetOrigin", &sf::Sprite::GetOrigin)
							.def("GetRotation", &sf::Sprite::GetRotation)
							.def("GetColor", &sf::Sprite::GetColor)
							.def("GetBlendMode", &sf::Sprite::GetBlendMode)
							.def("Move", (void(sf::Sprite::*)(float, float))&sf::Sprite::Move)
							.def("Move", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::Move)
							.def("Scale", (void(sf::Sprite::*)(float, float))&sf::Sprite::Scale)
							.def("Scale", (void(sf::Sprite::*)(const sf::Vector2f&))&sf::Sprite::Scale)
							.def("Rotate", &sf::Sprite::Rotate)
							.def("TransformToLocal", &sf::Sprite::TransformToLocal)
							.def("TransformToGlobal", &sf::Sprite::TransformToGlobal)
					];
			}
				
			void BString(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[							
						class_<sf::String>("String")
							.def(constructor<>())
							.def(constructor<char>())
							.def(constructor<char, const std::locale&>())
							.def(constructor<wchar_t>())
							.def(constructor<sf::Uint32>())
							.def(constructor<const char*>())
							.def(constructor<const std::string&>())
							.def(constructor<const char*, const std::locale&>())
							.def(constructor<const std::string&, const std::locale&>())
							.def(constructor<const wchar_t*>())
							.def(constructor<const std::wstring&>())
							.def(constructor<const sf::Uint32*>())
							.def(constructor<const std::basic_string<sf::Uint32>& >())
							.def(constructor<const sf::String&>())
							.def("ToAnsiString", (std::string(sf::String::*)() const)&sf::String::ToAnsiString)
							.def("ToAnsiString", (std::string(sf::String::*)(const std::locale&) const)&sf::String::ToAnsiString)
							.def("ToWideString", &sf::String::ToWideString)
							.def("Clear", &sf::String::Clear)
							.def("GetSize", &sf::String::GetSize)
							.def("IsEmpty", &sf::String::IsEmpty)
							.def("Erase", &sf::String::Erase)
							.def("Insert", &sf::String::Insert)
							.def("Find", &sf::String::Find)
							.def("GetData", &sf::String::GetData)
							.def("Begin", (sf::String::Iterator(sf::String::*)())&sf::String::Begin)
							.def("Begin", (sf::String::ConstIterator(sf::String::*)() const)&sf::String::Begin)
							.def("End", (sf::String::Iterator(sf::String::*)())&sf::String::End)
							.def("End", (sf::String::ConstIterator(sf::String::*)() const)&sf::String::End)
					];
			}

			void BText(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::Text, bases<sf::Drawable> >("Text")
							.def(constructor<>())
							.def(constructor<const sf::String&, const sf::Font&, unsigned int>())
							.def("SetString", &sf::Text::SetString)
							.def("SetFont", &sf::Text::SetFont)
							.def("SetCharacterSize", &sf::Text::SetCharacterSize)
							.def("SetStyle", &sf::Text::SetStyle)
							.def("GetString", &sf::Text::GetString)
							.def("GetFont", &sf::Text::GetFont)
							.def("GetCharacterSize", &sf::Text::GetCharacterSize)
							.def("GetStyle", &sf::Text::GetStyle)
							.def("GetCharacterPos", &sf::Text::GetCharacterPos)
							.def("GetRect", &sf::Text::GetRect)
							.def("SetPosition", (void(sf::Text::*)(float, float))&sf::Text::SetPosition)
							.def("SetPosition", (void(sf::Text::*)(const sf::Vector2f&))&sf::Text::SetPosition)
							.def("SetX", &sf::Text::SetX)
							.def("SetY", &sf::Text::SetY)
							.def("SetScale", (void(sf::Text::*)(float, float))&sf::Text::SetScale)
							.def("SetScale", (void(sf::Text::*)(const sf::Vector2f&))&sf::Text::SetScale)
							.def("SetScaleX", &sf::Text::SetScaleX)
							.def("SetScaleY", &sf::Text::SetScaleY)
							.def("SetOrigin", (void(sf::Text::*)(float, float))&sf::Text::SetOrigin)
							.def("SetOrigin", (void(sf::Text::*)(const sf::Vector2f&))&sf::Text::SetOrigin)
							.def("SetRotation", &sf::Text::SetRotation)
							.def("SetColor", &sf::Text::SetColor)
							.def("SetBlendMode", &sf::Text::SetBlendMode)
							.def("GetPosition", &sf::Text::GetPosition)
							.def("GetScale", &sf::Text::GetScale)
							.def("GetOrigin", &sf::Text::GetOrigin)
							.def("GetRotation", &sf::Text::GetRotation)
							.def("GetColor", &sf::Text::GetColor)
							.def("GetBlendMode", &sf::Text::GetBlendMode)
							.def("Move", (void(sf::Text::*)(float, float))&sf::Text::Move)
							.def("Move", (void(sf::Text::*)(const sf::Vector2f&))&sf::Text::Move)
							.def("Scale", (void(sf::Text::*)(float, float))&sf::Text::Scale)
							.def("Scale", (void(sf::Text::*)(const sf::Vector2f&))&sf::Text::Scale)
							.def("Rotate", &sf::Text::Rotate)
							.def("TransformToLocal", &sf::Text::TransformToLocal)
							.def("TransformToGlobal", &sf::Text::TransformToGlobal)
					];

				object style = newtable(lua);
				style["Regular"] = sf::Text::Style::Regular;
				style["Bold"] = sf::Text::Style::Bold;
				style["Italic"] = sf::Text::Style::Italic;
				style["Underlined"] = sf::Text::Style::Underlined;
				globals(lua)[ns.c_str()]["Text"]["Style"] = style;
			}			

			void BView(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sf::View>("View")
							.def(constructor<>())
							.def(constructor<const sf::FloatRect&>())
							.def(constructor<const sf::Vector2f&, const sf::Vector2f&>())
							.def("SetCenter", (void(sf::View::*)(float, float))&sf::View::SetCenter)
							.def("SetCenter", (void(sf::View::*)(const sf::Vector2f&))&sf::View::SetCenter)
							.def("SetSize", (void(sf::View::*)(float, float))&sf::View::SetSize)
							.def("SetSize", (void(sf::View::*)(const sf::Vector2f&))&sf::View::SetSize)
							.def("SetRotation", &sf::View::SetRotation)
							.def("SetViewport", &sf::View::SetViewport)
							.def("Reset", &sf::View::Reset)
							.def("GetCenter", &sf::View::GetCenter)
							.def("GetSize", &sf::View::GetSize)
							.def("GetRotation", &sf::View::GetRotation)
							.def("GetViewport", &sf::View::GetViewport)
							.def("Move", (void(sf::View::*)(float, float))&sf::View::Move)
							.def("Move", (void(sf::View::*)(const sf::Vector2f&))&sf::View::Move)
							.def("Rotate", &sf::View::Rotate)
							.def("Zoom", &sf::View::Zoom)
							.def("GetMatrix", &sf::View::GetMatrix)
							.def("GetInverseMatrix", &sf::View::GetInverseMatrix)
					];
			}
				
			void Bind(lua_State* lua, const std::string& ns)
			{
				open(lua);
				BDrawable(lua, ns);
				BColor(lua, ns);
				BFont(lua, ns);
				BGlyph(lua, ns);
				BImage(lua, ns);
				BRenderer(lua, ns);
				BRenderTarget(lua, ns);
				BRenderImage(lua, ns);
				BRenderWindow(lua, ns);
				BShader(lua, ns);
				BShape(lua, ns);
				BSprite(lua, ns);
				BString(lua, ns);
				BText(lua, ns);
				BView(lua, ns);
			}
		}
	}
}